<?php
declare (strict_types=1);

namespace app\admin\event\listeners\config;

use app\admin\logic\system\Log;

/**
 * Class UpdateConfigListeners
 *
 * @package app\admin\event\listeners\config
 */
class UpdateConfigListeners
{
    /**
     * 定义配置名称
     */
    const SYS_TITLES = [
        'site.info'                       => '站点配置',
        'site.theme.color'                => '主题色配置',
        'system.school.app'               => '机构独立APP配置',
        'site.personal.display'           => '个人中心排版配置',
        'site.course.display'             => '课程列表排版配置',
        'course.live.config.tic'          => '互动课堂直播配置',
        'course.live.config.cclive'       => 'CC直播配置',
        'course.live.config.agora'        => '声网直播配置',
        'course.live.config.netless'      => '声网直播白板配置',
        'course.config.comment_note'      => '评论与笔记配置',
        'course.cert.config'              => '证书配置',
        'system.login'                    => '登录配置',
        'system.login.oneclick'           => '一键登录配置',
        'system.login.miniapp'            => '小程序登录配置',
        'system.config.official'          => '公众号配置',
        'system.category'                 => '分类配置',
        'system.package.login'            => '第三方登录方式配置',
        'system.package.login.qq'         => 'QQ登录配置',
        'system.package.login.sina'       => '新浪微博登录配置',
        'system.package.login.weixin'     => '微信登录配置',
        'system.package.sms'              => '短信配置',
        'system.package.sms.tencent'      => '腾讯云短信配置',
        'system.package.sms.aliyun'       => '阿里云短信配置',
        'system.package.upload'           => '上传配置',
        'system.package.upload.local'     => '本地储存配置',
        'system.package.upload.aliyun'    => '阿里云储存配置',
        'system.package.upload.tencent'   => '腾讯云储存配置',
        'system.package.payment'          => '支付配置状态',
        'system.package.payment.alipay'   => '支付宝支付配置',
        'system.package.payment.wxpay'    => '微信支付配置',
        'system.package.payment.applepay' => '苹果支付配置',
        'face.config'                     => '人脸识别配置',
        'split.config'                    => '分成配置',
        'recharge.config'                 => '充值比例配置',
        'recharge.config.ios'             => 'IOS配置',
        'credit.redeem'                   => '兑换比例配置',
        'credit.threshold'                => '积分满用配置',
        'credit.order'                    => '订单满抵配置',
        'live_provider_used'              => '直播服务商',
        'course.video.marquee'            => '跑马灯配置',
        'exam.paper.config'               => '试卷配置',
        'system.onhook'                   => '防挂机配置',
    ];

    /**
     * handle
     * Author: Martinsun <syh@sunyonghong.com>
     * Date: 2021/7/19
     *
     * @static
     * @param $data
     */
    public static function handle($data)
    {
        $title = self::getConfigTitle($data['sys_key']);
        $admin = '管理员【' . request()->user->user_name . '/' . request()->user->id . '】';
        Log::write($admin . '更新了【' . $title . '】', 'system_config', 'update');
    }

    /**
     * 获取配置名称
     * Author: Martinsun <syh@sunyonghong.com>
     * Date: 2021/7/19
     *
     * @static
     * @param string $key
     * @return string
     */
    public static function getConfigTitle(string $key): string
    {
        return self::SYS_TITLES[$key] ?? '未知配置';
    }
}
